﻿using System.Collections;
using UnityEngine;
using UnityEngine.SceneManagement;

public class StartGame : MonoBehaviour
{
    private void OnEnable()
    {
        StartCoroutine(StartGameMethod());
    }

    private IEnumerator StartGameMethod()
    {
        Scene currentActiveScene = SceneManager.GetActiveScene();
        SceneManager.LoadScene("Persistent", LoadSceneMode.Additive); // 使用 Additive 模式加载新场景
        AsyncOperation ao = SceneManager.LoadSceneAsync("StartScene", LoadSceneMode.Additive); // 使用 Additive 模式加载新场景
        yield return ao;
        Scene newScene = SceneManager.GetSceneByName("StartScene");
        // 设置新加载的场景为活跃场景
        SceneManager.SetActiveScene(newScene);
        SceneManager.UnloadSceneAsync(currentActiveScene);
    }
}
